package echat.future.cn.echat.my.view;

import android.support.v7.widget.LinearLayoutManager;

import java.util.ArrayList;
import java.util.List;

import echat.future.cn.echat.R;
import echat.future.cn.echat.databinding.ActivityIntimateBinding;
import echat.future.cn.echat.my.adapter.IntimvateAdapter;
import echat.future.cn.echat.my.api.UserApi;
import echat.future.cn.echat.my.bean.IntimateBean;
import echat.future.cn.echat.my.utils.HttpUtilsRequst;
import echat.future.cn.echat.my.utils.UserHelper;
import echat.future.cn.echat.my.weight.Navagation.AdapterNavagation;
import echat.future.cn.echat.my.weight.Navagation.IBaseNavagation;

/**
 * 亲密得
 */
public class IntimateActivity extends BaseActivity<ActivityIntimateBinding>{

    private List<IntimateBean> mDatas = new ArrayList<>();

    private IntimvateAdapter intimvateAdapter;

    @Override
    public int layoutId() {
        return R.layout.activity_intimate;
    }

    @Override
    public IBaseNavagation navagation() {
        return new AdapterNavagation(this).setTitle("与我亲密的", 16, R.color.white).setBack(R.drawable.btn_back).setNavagationBackgroudColor(R.color.color_161823);
    }

    @Override
    public void initView() {
        intimvateAdapter = new IntimvateAdapter(this.mDatas);
        bind.recyclerView.setLayoutManager(new LinearLayoutManager(this));
        bind.recyclerView.setAdapter(intimvateAdapter);
        loadMore();
    }

    private void loadMore(){
        new HttpUtilsRequst<>(this,HttpUtilsRequst.retrofitClient.create(UserApi.class).getIntimateBeans(UserHelper.getToken(),UserHelper.getUserId()))
                .setmOnRequstSuccessListener((HttpUtilsRequst.OnRequstSuccessListener<List<IntimateBean>>) o -> {
                    mDatas.clear();
                    mDatas.addAll(o);
                    intimvateAdapter.notifyDataSetChanged();
                })
                .start();
    }

}
